# ---------- ---------- ---------- ---------- ---------- ----------
#
# owl_tinkering Makefile
#
# ---------- ---------- ---------- ---------- ---------- ----------


OWL_HOME=$(if $(i),$(i),ol)
CC=$(if $(c),$(c),gcc)
EXE=bin/hello


target: help


.PHONY: help
help:
	@echo "Usage: make [PHONY]"
	@sed -n -e "/sed/! s/\.PHONY: //p" Makefile
	@echo "To install owl locally:"
	@echo "    make deps && pushd lib/owl && make && popd"
	@echo "Then test it:"
	@echo "    make tests i=`pwd`/lib/owl/bin/ol"


.PHONY: deps
deps:
	@git clone https://gitlab.com/owl-lisp/owl.git lib/owl


.PHONY: build
build:
	@mkdir -p bin
	@$(OWL_HOME) -o bin/hello.c src/hello.scm
	@$(CC) -o $(EXE) bin/hello.c


.PHONY: run
run:
	@$(EXE)


.PHONY: tests
tests: clean build run


.PHONY: clean
clean:
	@rm -rf bin
